package pl.kaczanowscy.tomek.ipdl.strategy;

import pl.kaczanowscy.tomek.ipdl.RoundResult;
import pl.kaczanowscy.tomek.ipdl.Strategy;
import pl.kaczanowscy.tomek.ipdl.enums.Move;

/**
 * RAND - random.
 * 
 * @author Tomasz Kaczanowski
 */
public final class RAND implements Strategy {

	private static final double HALF = 0.5;

	/**
	 * DEFECTS or COOPERATES with 1/2 probability.
	 * 
	 * @see pl.kaczanowscy.tomek.ipdl.Strategy#getMove()
	 */
	public Move getMove() {
		return (Math.random() > HALF) ? Move.COOPERATION : Move.DEFECTION;
	}

	/**
	 * RAND does not care about the results of the last round.
	 * 
	 * @see pl.kaczanowscy.tomek.ipdl.RoundListener#roundEnded(pl.kaczanowscy.tomek.ipdl.RoundResult)
	 */
	@Override
	public void roundEnded(RoundResult result) {
		// RAND doesn't care
	}

}
